﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

[System.Serializable]
public class ItemCombination {

	public List<ExogenesisItem> Item_Ingredients;
	public ExogenesisItem Item_Product;

	public ItemCombination()
	{
		Item_Ingredients = new List<ExogenesisItem>();
	}

	public bool IsValidCombination(List<ExogenesisItem> ingredients)
	{
		bool ret = true;

		for(int i = 0; i < ingredients.Count; i++)
		{

			if(!Item_Ingredients.Contains(ingredients[i]))
			{
				ret = false;
				break;
			}

		}

		return ret;
	}

	public ExogenesisItem[] GetIngredients{
		get {
				ExogenesisItem[] ret = new ExogenesisItem[Item_Ingredients.Count];
				Item_Ingredients.CopyTo(ret, 0);
				return ret;
			}
	}

	public bool IsValidCombination(ExogenesisItem[] ingredients)
	{
		bool ret = true;
		
		for(int i = 0; i < ingredients.Length; i++)
		{
			
			if(!Item_Ingredients.Contains(ingredients[i]))
			{
				ret = false;
				break;
			}
			
		}
		
		return ret;
	}

	//Combines the item using this combination and then updates the player inventory;
	public ExogenesisItem CombineItems(List<ExogenesisItem> playerInventory)
	{
		for(int i = 0; i < Item_Ingredients.Count; i++)
		{
			playerInventory.Remove(Item_Ingredients[i]);
		}

		ExogenesisItem product = Item_Product;
		playerInventory.Add(product);

		return product;
	}

}
